home *** CD-ROM | disk | FTP | other *** search
- /* EventLoop.c */ /* C14 Calculator */
-
- /*-----------*/
- /*#include <Types.h>*/
- /*#include <Quickdraw.h>*/
- /*#include <Controls.h>*/
- /*#include <Desk.h>*/
- /*#include <Dialogs.h>*/
- /*#include <DiskInit.h>*/
- /*-----------*/
-
- #include <Editions.h>
-
- /*-----------*/
- #include <EPPC.h>
- #include <Events.h>
- /*#include <Fonts.h>*/
- /*-----------*/
-
-
- #include <GestaltEqu.h>
-
- /*-----------*/
- /*#include <Lists.h>*/
- /*#include <Menus.h>*/
- #include <OSEvents.h>
- /*#include <TextEdit.h>*/
- /*#include <ToolUtils.h>*/
- /*-----------*/
-
- #include <Traps.h>
-
- #include <AppleEvents.h>
- #include "Globals.h"
- #include "Miscellany.h"
- #include "AEvent.h"
- #include "EventLoop.h"
-
- #include "DoScrap.h"
- #include "WindowAids.h"
- #include "Dispatcher.h"
-
- #ifndef __RED__
- #include "ResourceDefs.h"
- #endif
- //#include <OSUtils.h>
-
- void EventLoopSeg() {}
-
- /*----------*/
- #ifndef THINK_C
- extern void _DataInit (void);
- #endif
-
-
- /*----------*/
- /*Boolean TrapAvailable (short tNumber,
- TrapType tType);
- Boolean TrapAvailable (short tNumber,
- TrapType tType)
- {
- return (NGetTrapAddress (tNumber, tType)
- != GetTrapAddress (_Unimplemented));
- } *//*TrapAvailable*/
-
- /*----------*/
- void SetStackSize (long stackSize);
- void SetStackSize (long stackSize)
- {
- SetApplLimit ((Ptr) ((long) &stackSize - stackSize));
- } /*SetStackSize*/
-
-
- /*----------*/
- static void GetSysConfig (void);
- static void GetSysConfig (void)
- {
- OSErr ignoreError;
- long tempLong; /*for Gestalt*/
- SysEnvRec environs;
-
- sysConfig.hasGestalt = (Gestalt (gestaltVersion, &tempLong) == noErr);
- if (sysConfig.hasGestalt) {
- sysConfig.hasWNE = true;
- ignoreError = Gestalt (gestaltQuickdrawVersion, &tempLong);
- sysConfig.hasColorQD = (tempLong != gestaltOriginalQD);
- sysConfig.hasAppleEvents = (Gestalt (gestaltAppleEventsAttr, &tempLong) == noErr);
- sysConfig.hasEditionMgr = (Gestalt (gestaltEditionMgrAttr, &tempLong) == noErr);
- if (sysConfig.hasEditionMgr) {
- if (!CheckOS (InitEditionPack ())) {
- sysConfig.hasEditionMgr = false; /*unable to load Edition Manager package*/
- }
- }
- } else {
- ignoreError = SysEnvirons (curSysEnvVers, &environs);
- if (environs.machineType < 0) {
- sysConfig.hasWNE = false;
- } else {
- sysConfig.hasWNE = true;
- }
- sysConfig.hasColorQD = environs.hasColorQD;
- sysConfig.hasAppleEvents = false;
- sysConfig.hasEditionMgr = false;
- }
- } /*GetSysConfig*/
- /*----------*/
- void DoUpdate (EventRecord gTheEvent)
- {
- GrafPtr savePort;
- WindowPtr saveWindow;
- WindowPtr whichWindow;
-
- GetPort (&savePort);
- whichWindow = (WindowPtr) gTheEvent.message;
- SetPort (whichWindow);
- saveWindow = curWindow;
- SetInfo (whichWindow);
- BeginUpdate (whichWindow);
- EraseRect (&(whichWindow->portRect));
- DrawControls (whichWindow);
- UpdateContent (); /* Dispatcher.c */
- EndUpdate (whichWindow);
- SetInfo (saveWindow);
- SetPort (savePort);
- } /*DoUpdate*/
-
-
- /*----------*/
- void DoActivate (EventRecord gTheEvent)/*(WindowPtr whichWindow)*/
- {
- Boolean activate;
- WindowPtr whichWindow;
-
- whichWindow = (WindowPtr) /*curEvent*/gTheEvent.message;
- SetPort (whichWindow);
- SetInfo (whichWindow);
-
- activate = ((/*curEvent*/gTheEvent.modifiers & activeFlag) != 0);
- if (activate) {
- if ((cur->text) != NULL) {
- TEActivate (cur->text);
- }
- ReadDeskScrap ();
- }
-
- HiliteScroll (cur->vScroll, activate);
- /*HiliteScroll (cur->hScroll, activate);*/
-
- ActivateContent (activate);
-
- if (!activate) {
- WriteDeskScrap ();
- if (cur->text != NULL) {
- TEDeactivate (cur->text);
- }
- SetInfo (NULL);
- }
- } /*DoActivate*/
-
- void DoGetSysConfig(void)
- {
-
- #if defined(applec) /* MPW C */
- UnloadSeg ((Ptr) _DataInit);
- #endif /* MPW C */
-
- GetSysConfig ();
- if (sysConfig.hasAppleEvents) {
- InitializeAE ();
- }
- }
-
- void DoSetStackSize(void)
- {
-
- #if defined(applec) /* MPW C */
- UnloadSeg ((Ptr) _DataInit);
- #endif /* MPW C */
-
-
- /*SetStackSize (15000);*/
- SetStackSize (16000);
- }